package com.example.makerspace.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.makerspace.domain.BookDO;
import com.example.makerspace.mapper.BookMapper;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Component
public class BookDAO extends BaseDAO<BookDO>{
    @Resource
    private BookMapper bookMapper;

    @PostConstruct
    public void init(){
        this.mapper = bookMapper;
    }

    public final static String BOOK_NAME = "book_name";

    public BookDO selectById(Integer id){
        return bookMapper.selectById(id);
    }

    public BookDO selectByBookName(String bookName){
        return bookMapper.selectOne(new QueryWrapper<BookDO>().eq(BOOK_NAME, bookName));
    }
}
